package com.yy.jhl.ui.manager.presenter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yy.jhl.api.Api;
import com.yy.jhl.api.RxSubscriber;
import com.yy.jhl.bean.ProductInfo;
import com.yy.jhl.bean.SealBoxListInfo;
import com.yy.jhl.ui.manager.adapter.ProductAdapter;
import com.yy.jhl.ui.manager.contract.ProductListContract;
import com.yy.jhl.ui.manager.contract.SealBoxListContract;

import java.util.List;

import okhttp3.ResponseBody;

/**
 * Created by libingn on 2017/12/14.
 */

public class ProductListPresenter extends ProductListContract.Presenter {
    @Override
    public void getList(String orderId,String batchId) {
        mRxManage.addSubscription(Api.getDefault().gysGetProductList(orderId,batchId), new RxSubscriber<ResponseBody>(mContext,true) {
            @Override
            protected void _onNext(String result) {
                List<ProductInfo> retList = new Gson().fromJson(result,
                        new TypeToken<List<ProductInfo>>() {
                        }.getType());
                mView.getListSuccess(retList);
            }

            @Override
            protected void _onError(String message) {
                mView.getListFail();
            }
        });
    }
}
